package kuaidi.view.activity;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import kuaidi.helper.R;
import kuaidi.utils.FragmentTabUtils;
import kuaidi.utils.RecordSQLiteOpenHelper;
import kuaidi.view.fragment.ChakuaidiFragment;
import kuaidi.view.fragment.JikuaidiFragment;
import kuaidi.view.fragment.ShouyeFragment;

public class MainActivity extends AppCompatActivity {

    @BindView(R.id.main_ll)
    LinearLayout mainLl;
    @BindView(R.id.main_shouye)
    RadioButton mainShouye;
    @BindView(R.id.main_chakuaidi)
    RadioButton mainChakuaidi;
    @BindView(R.id.main_jikuaidi)
    RadioButton mainJikuaidi;
    @BindView(R.id.main_rg)
    RadioGroup mainRg;
    @BindView(R.id.activity_main)
    RelativeLayout activityMain;
    private List<Fragment> data;
    FragmentManager manager;
    FragmentTabUtils tabUtils;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        initData();
        severfrg();

    }

    private void severfrg() {

        tabUtils = new FragmentTabUtils(manager, data, R.id.main_ll, mainRg, new FragmentTabUtils.OnRgsExtraCheckedChangedListener() {
            @Override
            public void OnRgsExtraCheckedChanged(RadioGroup radioGroup, int checkedId, int index) {
            }
        });
    }

    private void initData() {
        creatdb();
        manager = getSupportFragmentManager();
        data = new ArrayList<>();
        data.add(ShouyeFragment.newInstance());
        data.add(ChakuaidiFragment.newInstance());
        data.add(JikuaidiFragment.newInstance());
    }

    private void creatdb() {
        File f=new File("/data/data/<app_package_path>/database/kdno.db");
        if (f.exists()){
            RecordSQLiteOpenHelper helper=new RecordSQLiteOpenHelper(this);

        }else {

        }
    }


}
